package com.angel.webapp.application;

import com.angel.common.keyValue.KeyValueResult;
import com.angel.common.keyValue.impl.KeyValueResultImpl;

/**
 * @author William
 * @since 03/February/2009
 */
public class ApplicationUserGenerators {

    private static ApplicationUserGenerators INSTANCE;

    private KeyValueResult keyValueResult;

    private ApplicationUserGenerators(){
        super();
        this.setKeyValueResult(new KeyValueResultImpl());
    }

    public synchronized static ApplicationUserGenerators createInstance(){
        if(INSTANCE == null){
            INSTANCE = new ApplicationUserGenerators();
        }
        return INSTANCE;
    }

    public KeyValueResult getKeyValueResult() {
        return keyValueResult;
    }

    public void setKeyValueResult(KeyValueResult keyValueResult) {
        this.keyValueResult = keyValueResult;
    }

    public Class<?> findUserGenerator(String name){
        return (Class<?>) this.getKeyValueResult().getResultFor(name);
    }
    
    public void removeUserGenerator(String name){
        this.getKeyValueResult().removeKeyValue(name);
    }
    
    public void addUserGenerator(String name, Class<?> userGeneratorClass){
        this.getKeyValueResult().addKeyValue(name, userGeneratorClass);
    }

    public boolean containsUserGenerator(String name){
        return this.keyValueResult.containsResultFor(name);
    }
}